package com.ysxsoft.wdg.net;


import com.ysxsoft.wdg.bean.AddressBean;
import com.ysxsoft.wdg.bean.BannerBean;
import com.ysxsoft.wdg.bean.BaseBean;
import com.ysxsoft.wdg.bean.DiscussBean;
import com.ysxsoft.wdg.bean.DiscussBean2;
import com.ysxsoft.wdg.bean.MyJfBean;
import com.ysxsoft.wdg.bean.ZyOrderBean;
import com.ysxsoft.wdg.bean.UserInfoBean;
import com.ysxsoft.wdg.bean.cart.ShopcartBean;
import com.ysxsoft.wdg.bean.cart.ShopcartConfirmBean;
import com.ysxsoft.wdg.bean.home.HomeBannerBean;
import com.ysxsoft.wdg.bean.home.InviteBean;
import com.ysxsoft.wdg.bean.response.ShareCodeResponse;
import com.ysxsoft.wdg.bean.st.CompanyBean;
import com.ysxsoft.wdg.bean.st.StGoodsBean;
import com.ysxsoft.wdg.bean.st.StHomeBean;
import com.ysxsoft.wdg.bean.st.StShopDetailBean;
import com.ysxsoft.wdg.bean.zy.CreateIdBean;
import com.ysxsoft.wdg.bean.zy.GoodsBean;
import com.ysxsoft.wdg.bean.zy.GoodsRulesBean;
import com.ysxsoft.wdg.bean.zy.RuleBean;
import com.ysxsoft.wdg.bean.zy.ZyConfirmBean;
import com.ysxsoft.wdg.bean.zy.ZyGoodsBean;
import com.ysxsoft.wdg.bean.zy.ZyOrderDetailBean;
import com.ysxsoft.wdg.pay.WxPayBean;
import com.ysxsoft.wdg.upversion.VersionBean;
import com.ysxsoft.wdg.util.sp.SharePrefUtils;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;


public class ApiHelper {
    protected ApiService mApiService;

    public ApiHelper() {
        mApiService = HttpClient.getInstance().getApiService();
    }

    /**
     * 上传图片
     */
    public void commitPic(String path, Observer<BaseBean<UserInfoBean>> observer) {
        Map<String, RequestBody> params = new HashMap<>();
        params.put("uid", convertToRequestBody(SharePrefUtils.getUserId()));
        mApiService.commitPic(params, createPart("file", path))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    private MultipartBody.Part createPart(String key, String path) {
        File file = new File(path);
        RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
        return MultipartBody.Part.createFormData(key, file.getName(), requestBody);
    }

    private RequestBody convertToRequestBody(String param) {
        return RequestBody.create(MediaType.parse("text/plain"), param);
    }


    /**
     * 注册
     */
    public void postRegister(String mobile, String code, String invicode, String password, String province, String city, String county,
                             Observer<BaseBean> observer) {
        mApiService.postRegister(mobile, code, invicode, password, province, city, county)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 获取验证码
     */
    public void getMsmCode(String mobile, Observer<BaseBean<String>> observer) {
        mApiService.getMsmCode(mobile)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 登录
     */
    public void postLogin(String username, String password,String a_cid, Observer<BaseBean<UserInfoBean>> observer) {
        mApiService.postLogin(username, password,a_cid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 修改密码 忘记密码
     */
    public void modifyPsw(String mobile, String code, String pass, String repass, Observer<BaseBean> observer) {
        mApiService.modifyPsw(mobile, code, pass, repass)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 热门城市
     */
    public void getHotCity(Observer<BaseBean<List<BannerBean>>> observer) {
        mApiService.getHotCity()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 个人信息
     */
    public void getUserInfo(String uid, Observer<BaseBean<UserInfoBean>> observer) {
        mApiService.getUserInfo(uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 修改 头像，昵称，性别
     */
    public void modifyPersonInfo(String uid, String avatar, String nickname, String sex, String province,
                                 String city, String county, Observer<BaseBean> observer) {
        mApiService.modifyPersonInfo(uid, avatar, nickname, sex, province, city, county)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 账号与安全
     */
    public void getAccountInfo(String uid, Observer<BaseBean<UserInfoBean>> observer) {
        mApiService.getAccountInfo(uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 修改手机号
     */
    public void modifyPhone(String uid, String code, String mobile, Observer<BaseBean> observer) {
        mApiService.modifyPhone(uid, code, mobile)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 账号绑定
     */
    public void bindAli(String uid, String name, String alicode, String code, Observer<BaseBean> observer) {
        mApiService.bindAli(uid, name, alicode, code)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 意见反馈
     */
    public void postYjfk(String uid, String content, Observer<BaseBean> observer) {
        mApiService.postYjfk(uid, content)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 服务条款
     */
    public void getFwlk(Observer<BaseBean<String>> observer) {
        mApiService.getFwlk()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }


    /**
     * 版本
     */
    public void getVersion(Observer<BaseBean<VersionBean>> observer) {
        mApiService.getVersion()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 我的客服
     */
    public void getKf(Observer<BaseBean<UserInfoBean>> observer) {
        mApiService.getKf()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 首页轮播图
     */
    public void getHomeBanner(Observer<BaseBean<HomeBannerBean>> observer) {
        mApiService.getHomeBanner()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }


    /**
     * 收货地址
     */
    public void getAddressList(String uid, Observer<BaseBean<List<AddressBean>>> observer) {
        mApiService.getAddressList(uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 添加收货地址
     */
    public void addAddress(String uid, String province, String city, String county, String address, String name, String phone, String status, Observer<BaseBean<String>> observer) {
        mApiService.addAddress(uid, province, city, county, address, name, phone, status)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 修改地址
     */
    public void editAddress(String aid, String province, String city, String county, String address, String name, String phone, String status, Observer<BaseBean<String>> observer) {
        mApiService.editAddress(aid, province, city, county, address, name, phone, status)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 修改地址
     */
    public void delAddress(String aid, Observer<BaseBean> observer) {
        mApiService.delAddress(aid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 设置默认地址
     */
    public void addressStatus(String aid, Observer<BaseBean> observer) {
        mApiService.addressStatus(aid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 轮播
     */
    public void getZyBanner(Observer<BaseBean<List<BannerBean>>> observer) {
        mApiService.getZyBanner()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 热卖品
     */
    public void getZyHotList(String page, String cate, String keyword, String xu, String uid, Observer<BaseBean<List<GoodsBean>>> observer) {
        mApiService.getZyHotList(page, cate, keyword, xu, uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 商品详情
     */
    public void getZyGoodsdetail(String uid, String goodsid, Observer<BaseBean<ZyGoodsBean>> observer) {
        mApiService.getZyGoodsdetail(uid, goodsid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 评价列表
     */
    public void getZyDiscussList(String productid, String page, Observer<BaseBean<List<DiscussBean2>>> observer) {
        mApiService.getZyDiscussList(productid, page)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城 商品评价列表
     */
    public void getZyDiscussList2(String productid, String page,String type, Observer<BaseBean<List<DiscussBean2>>> observer) {
        mApiService.getZyDiscussList2(productid, page,type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 商品收藏
     */
    public void colZyGoods(String productid, String uid, Observer<BaseBean> observer) {
        mApiService.colZyGoods(productid, uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 商品规格
     */
    public void getZyRules(String goodsid, Observer<BaseBean<GoodsRulesBean>> observer) {
        mApiService.getZyRules(goodsid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 选择规格
     */
    public void chooseRule(String productid, String ruleid, Observer<BaseBean<GoodsBean>> observer) {
        mApiService.chooseRule(productid, ruleid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 加入购物车
     */
    public void addCart(String uid, String product_rule_id, String num, Observer<BaseBean> observer) {
        mApiService.addCart(uid, product_rule_id, num)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 确认订单
     */
    public void sureZyOrder(String uid, String product_rule_id, String num, Observer<BaseBean<ZyConfirmBean>> observer) {
        mApiService.sureZyOrder(uid, product_rule_id, num)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 生成订单
     */
    public void orderAdd(String uid, String addressid, String account, String product_rule_id, String num, Observer<BaseBean<CreateIdBean>> observer) {
        mApiService.orderAdd(uid, addressid, account, product_rule_id, num)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 余额支付
     */
    public void payZyYue(String uid, String orderid, String total, String type, Observer<BaseBean> observer) {
        mApiService.payZyYue(uid, orderid, total, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 微信支付
     */
    public void payZyWx(String uid, String orderid, String total, String type, Observer<BaseBean<WxPayBean>> observer) {
        mApiService.payZyWx(uid, orderid, total, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 支付宝
     */
    public void payZyZfb(String uid, String orderid, String total, String type, Observer<BaseBean<String>> observer) {
        mApiService.payZyZfb(uid, orderid, total, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 首页分类
     */
    public void getZyCate(Observer<BaseBean<List<BannerBean>>> observer) {
        mApiService.getZyCate()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 热门分类
     */
    public void getZyHotCate(Observer<BaseBean<List<BannerBean>>> observer) {
        mApiService.getZyHotCate()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 搜索历史记录
     *
     * @param uid
     * @param type 1首页2热门3自营4实体
     * @return
     */
    public void getHisSearch(String uid, String type, Observer<BaseBean<List<BannerBean>>> observer) {
        mApiService.getHisSearch(uid, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 清空历史记录
     *
     * @param uid
     * @param type 1首页2热门3自营4实体
     * @return
     */
    public void clearHisSearch(String uid, String type, Observer<BaseBean> observer) {
        mApiService.clearHisSearch(uid, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 分类商品列表
     */
    public void getZyCateList(String page, String categoryid, String xu, Observer<BaseBean<List<GoodsBean>>> observer) {
        mApiService.getZyCateList(page, categoryid, xu)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 分类商品列表 从自营分类点进去
     */
    public void getZyCateListByCategory(String page, String categoryid, String xu, Observer<BaseBean<List<GoodsBean>>> observer) {
        mApiService.getZyCateListByCategory(page, categoryid, xu)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 搜索页列表
     */
    public void getZySearchList(String page, String keyword, String type, String uid, Observer<BaseBean<List<GoodsBean>>> observer) {
        mApiService.getZySearchList(page, keyword, type, uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 自营商城 分类页
     */
    public void getZyFenlei(Observer<BaseBean<List<RuleBean>>> observer) {
        mApiService.getZyFenlei()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  分类
     */
    public void getStCate(Observer<BaseBean<List<BannerBean>>> observer) {
        mApiService.getStCate()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  首页
     */
    public void getStHome(String address, String lng, String lat, Observer<BaseBean<StHomeBean>> observer) {
        mApiService.getStHome(address, lng, lat)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  店铺详情
     */
    public void getStShopDetail(String companyid, String uid, Observer<BaseBean<StShopDetailBean>> observer) {
        mApiService.getStShopDetail(companyid, uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  商品详情
     */
    public void getStGoodsDetail(String productid, Observer<BaseBean<StGoodsBean>> observer) {
        mApiService.getStGoodsDetail(productid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  分类下的商铺
     *
     * @param page
     * @param categoryid
     * @param address
     * @param lng
     * @param lat
     * @param type       按距离升序降序type=1/2
     * @param price      价格升序降序1/2
     * @param grade      评分升序降序1/2
     * @return
     */
    public void getStCateList(String page, String categoryid, String address, String lng, String lat,
                              String type, String price, String grade, Observer<BaseBean<List<CompanyBean>>> observer) {
        mApiService.getStCateList(page, categoryid, address, lng, lat, type, price, grade)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }


    /**
     * 实体商城  附近商家
     *
     * @param page
     * @param address
     * @param lng
     * @param lat
     * @param xu      1距离正序2倒序3价格正序4倒序5评分倒序6正序
     * @return
     */
    public void getStFjList(String page, String address, String lng, String lat,
                            String xu, Observer<BaseBean<List<CompanyBean>>> observer) {
        mApiService.getStFjList(page, address, lng, lat, xu)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  搜索列表
     *
     * @param page
     * @param address
     * @param lng
     * @param lat
     * @param xu      1距离正序2倒序3价格正序4倒序5评分倒序6正序
     * @return
     */
    public void getStSearchList(String uid, String keyword, String page, String address,
                                String lng, String lat, String xu, Observer<BaseBean<List<CompanyBean>>> observer) {
        mApiService.getStSearchList(uid, keyword, page, address, lng, lat, xu)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  生成订单orderID
     */
    public void createStOrder(String uid, String account, String product_rule_id, String num,
                              String companyid, Observer<BaseBean<CreateIdBean>> observer) {
        mApiService.createStOrder(uid, account, product_rule_id, num, companyid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  余额支付
     */
    public void payStYuE(String uid, String orderid, String total,String quanid, Observer<BaseBean> observer) {
        mApiService.payStYuE(uid, orderid, total, "3",quanid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  支付宝
     */
    public void payStZfb(String uid, String orderid, String total,String quanid, Observer<BaseBean<String>> observer) {
        mApiService.payStZfb(uid, orderid, total, "2",quanid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 实体商城  微信
     */
    public void payStWx(String uid, String orderid, String total,String quanid, Observer<BaseBean<WxPayBean>> observer) {
        mApiService.payStWx(uid, orderid, total, "1",quanid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 购物车列表
     */
    public void getCartList(String uid, Observer<BaseBean<List<ShopcartBean>>> observer) {
        mApiService.getCartList(uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 加减购物车
     */
    public void editCartNum(String uid, String cardid, String num, Observer<BaseBean> observer) {
        mApiService.editCartNum(uid, cardid, num)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 删除购物车
     */
    public void delCart(String uid, String cardid, Observer<BaseBean> observer) {
        mApiService.delCart(uid, cardid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 购物车   确认订单
     */
    public void sureCartOrder(String uid, String cardid, Observer<BaseBean<ShopcartConfirmBean>> observer) {
        mApiService.sureCartOrder(uid, cardid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 购物车   生成订单orderId
     */
    public void createCartOrder(String uid, String cardid, String addressid, String account, String yun, Observer<BaseBean<CreateIdBean>> observer) {
        mApiService.createCartOrder(uid, cardid, addressid, account, yun)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 我的积分
     */
    public void getJfInfo(String uid, Observer<BaseBean<MyJfBean>> observer) {
        mApiService.getJfInfo(uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 积分商品详情
     */
    public void getJfGoodsDetail(String goodsid, Observer<BaseBean<MyJfBean.ShopBean>> observer) {
        mApiService.getJfGoodsDetail(goodsid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 签到
     */
    public void signUp(String uid, Observer<BaseBean> observer) {
        mApiService.signUp(uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 分享邀请页面
     */
    public void getInviteList(String uid, String page, Observer<BaseBean<InviteBean>> observer) {
        mApiService.getInviteList(uid, page)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 获取邀请码
     */
    public void getInviteCode(String uid, Observer<BaseBean<ShareCodeResponse>> observer) {
        mApiService.getInviteCode(uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 我的订单----自营商城
     *
     * @param uid
     * @param page
     * @param type  0全部1待付款2待发货3待收货4待评价5退款
     * @param style 0自营商城3满减
     */
    public void getZyOrderList(String uid, String page, String type, String style, Observer<BaseBean<List<ZyOrderBean>>> observer) {
        mApiService.getZyOrderList(uid, page, type, style)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }

    /**
     * 我的订单----自营商城
     */
    public void getZyOrderDetail(String uid, String orderid, Observer<BaseBean<ZyOrderDetailBean>> observer) {
        mApiService.getZyOrderDetail(uid, orderid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(observer);
    }


}
